<div class="container-fluid" style="margin: 0px 15px 0px 15px;">
<ol class="breadcrumb">
  <li><a href="<?php echo base_url('/index.php/inicio');?>">Inicio</a></li>
  <li><a href="<?php echo base_url('index.php/empenhos/consulta');?>">Empelho</a></li>
  <li class="active">Novo</li>
</ol>
		<div class="clone-wrapper">
				<fieldset class="cad">
					<legend>Cadastrar Empenho</legend>
					<form class="form-horizontal" role="form" id="form">
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">Selecione o Ano</label>
							<div class="col-sm-1">
								<input type="text" id="numero_protocolo"  name="numero_protocolo" value="" class="form-control input-sm" id="" placeholder="">
							</div>
						</div>
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">Selecione o setor (Destino)</label>
							<div class="col-sm-2">
								<input type="text" id="dt_protocolo" name="dt_protocolo" value=""  class="form-control input-sm"  placeholder="">
							</div>
						</div>
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">Selecione a secretaria</label>
							<div class="col-sm-1">
								<input type="text" id="numero_ci" name="numero_ci" value=""  class="form-control input-sm"  placeholder="">
							</div>
						</div>
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">Data Entrada</label>
							<div class="col-sm-4">
								<input type="email" id="credor" name="credor" value=""  class="form-control input-sm"  placeholder="">
							</div>
						</div>
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">Período</label>
							<div class="col-sm-2">
								<input type="text" class="form-control input-sm" value=""  id="valor" name="valor" placeholder="">
							</div>
						</div>
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">Status</label>
							<div class="col-sm-3">
								<select class="form-control input-sm" id="status" name="status">
								<option value="">TESTE</option>
								<option value="">TESTE</option>
								<option value="">TESTE</option>
								
								</select>
							</div>
						</div>
						<div class="form-group">
							<div class="col-sm-offset-2 col-sm-10">
							<?php 
								$data = array('name'=>'salvar','type' => 'submit','class' => 'btn btn-primary','content' =>'Salvar');
								echo form_button($data);
							?>
							<a id="cancelar" href="<?php echo base_url('index.php/contatos/consulta');?>" class="btn btn-default"></span>Cancelar</a>
							</div>
						</div>
				</form>
					</fieldset>
		</div>



</div>
	<script src="<?php echo base_url('includes/js/jquery-cloneya.js')?>"></script>
	
	<script language="javascript" type="text/javascript">
	$(document).ready(function(){
		$("#dt_protocolo").focus();
		$("#setor").autocomplete({
					source: "<?php echo base_url('index.php/ramais/consultaJson');?>",
					minLength: 2,
					select: function( event, ui ) {
						$("#idramal").val(ui.item.id);
					}
		});
		$('#form').validate({  
			rules: {  
				ramal: { 
							required: true, 
							remote:'<?php echo base_url('index.php/ramais/validaCadRamal');?>'
						},
				contato: {
						required:true,
						remote : {
							url : '<?php echo base_url('index.php/contatos/valida');?>',
							type : 'get',
							data : {
								'contato':function(){
									return $('#contato').val();},
								'idramal': function(){
									return $('#idramal').val();}
							}
							
						},
				},
				cargo: { required: true }
				
			},  
			messages: {  
				ramal: { required: 'Preencha o campo', remote: 'Ramal nao existe!' },
				contato: { required: 'Preencha o campo', remote: ' Contato ja cadastrado neste ramal!'},
				cargo: { required: 'Preencha o campo'}
			},
			submitHandler: function( form ){  
				var dados = $( form ).serialize();  
				$.ajax({  
					type: "POST",  
					url: "<?php echo base_url('index.php/contatos/salvar');?>",  
					data: dados,  
					success: function( data )  
					{  
						alertify.alert( data );
						/* $("#contato").val('');
						$("#cargo").val('');
						$("#cargo").val('');
						$("#tag").val(''); */
						$("#contato").focus();
					}  
				});  
				return false;  
			} 
		}); 
	});
		
	</script>
	</body>
</html>